fix(database-pgsql): normalise jsonb → json in introspector type map#69
Conversation
PgSqlGenerator maps entity type 'json' to JSONB in DDL, which is correct (JSONB is preferred in PostgreSQL for indexing and performance). However, the introspector returned 'jsonb' for those columns, while the entity schema still held 'json'. With no alias in Column::typeEquals(), the diff calculator reported a spurious Modify on every json column after the initial migration. Mapping 'jsonb' → 'json' in PgSqlIntrospector::TYPE_MAP normalises the round-trip so introspected JSONB columns compare equal to entity-declared json columns. The fix is intentionally scoped to the PgSQL driver — MySQL is unaffected (it stores and introspects JSON under the same name). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Thanks @michalbiarda — clean, narrowly-scoped fix. The asymmetry between I particularly like the end-to-end test ( Verified on |
Summary
PgSqlGeneratormaps entity typejson→JSONBin DDL (correct — JSONB is preferred in PostgreSQL)PgSqlIntrospectorread the column back asjsonb, while the entity schema heldjsonColumn::typeEquals()for this pair, so the diff calculator reported a spuriousModifyon everyjsoncolumn indefinitely'jsonb' => 'json'inPgSqlIntrospector::TYPE_MAP, normalising the round-trip at the driver levelCloses #68
Steps to reproduce (before fix)
#[Column(type: 'json')]db:migrate— column is created asJSONBin PostgreSQLdb:diff— reportsModify columndespite no changesExpected behavior
db:diffreports no changes after the column has been created.Test plan
it normalises jsonb to json so introspected columns match entity-declared typeit produces no diff when entity declares json and database stores jsonb🤖 Generated with Claude Code